package com.gagakuai.engine.impl.persistence.entity;

import com.gagakuai.engine.impl.pvm.process.ActivityImpl;
import com.gagakuai.engine.impl.pvm.process.ProcessDefinitionImpl;

import java.util.ArrayList;

/*
 * @program: common-starters
 * @description: 流程定义实体
 * @author: houhong
 * @create: 2023-01-02 15:12
 */
public class ProcessDefinitionEntity extends ProcessDefinitionImpl {

    protected String key;
    protected int revision = 1;
    protected int version;
    protected String category;
    protected String deploymentId;
    protected String resourceName;


    public ExecutionEntity createProcessInstance(String businessKey) {
        return createProcessInstance(businessKey, null);
    }

    public ExecutionEntity createProcessInstance(String businessKey, ActivityImpl initial) {

        ExecutionEntity processInstance = null;

        if (initial == null) {
            processInstance = (ExecutionEntity) super.createProcessInstance();
        } else {
            processInstance = (ExecutionEntity) super.createProcessInstanceForInitial(initial);
        }
        processInstance.setExecutions(new ArrayList<>());


        return processInstance;
    }

    @Override
    public ExecutionEntity createProcessInstance() {
        return createProcessInstance(null);
    }

}